package com.axzhengxin.platform.common.util;

import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author AHZJ0005
 * 生产snakeID主键
 */
@Component
public class IdUtils {
    @Value("${systemConfig.workerId:#{null}}")
    private Long workId;

    @Value("${systemConfig.datacenterId:#{null}}")
    private Long datacenterId;


    public String getSnakeId(){
        String snakeId = IdUtil.getSnowflake(workId, datacenterId).nextIdStr();
        return snakeId;
    }
}
